package day04;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 创建一个List集合，并存放10个随机数，然后排序该集合
 * 后输出
 * @author Bonnie
 *
 */
public class Test07 {
    public static void main(String[] args) {
        ArrayList list=new ArrayList();
        for (int i = 0; i < 10; i++) {
            list.add((int) (Math.random()*20));
        }
        System.out.println(list);
        //Collections.sort(list);
        for (int i = 0; i < list.size()-1; i++) {
            for (int j = 0; j < list.size()-1-i; j++) {
                if ( (Integer)list.get(j)>(Integer) list.get(j+1)){
                    Integer c = (Integer)list.get(j);
                    Integer c1 = (Integer)list.get(j+1);
                    list.set(j+1,c);
                    list.set(j,c1);
                }
            }
        }
        System.out.println(list);

    }

}
